package Day35.test1;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        ProductOperate productOperate = new ProductOperate();
        for (int i = 0; i < 10; i++) {
            Product product = new Product();
            product.setProNo(1000+i);
            product.setProName("手机"+i);
            product.setProPrice(1000f*(i+1));
            product.setProNum(1+i);
            product.setProSize(6.8);
            try {
                productOperate.addProduct(product);
                System.out.println("添加第"+(i+1)+"个商品");
            } catch (NullPointerException e) {
                System.out.println("商品添加失败");
            }
        }


        //查看库存
        productOperate.queryProducts();
        try {
            System.out.println("修改库存数量:");
            Scanner input = new Scanner(System.in);
            System.out.print("请输入要修改的商品的商品编号:");
            int no = input.nextInt();
            System.out.print("要更新的库存量(减少请输入负数):");
            int num = input.nextInt();
            productOperate.updateProductNum(no,num);
            System.out.println("库存更新成功!");
            //查看库存
            productOperate.queryProducts();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }


    }
}
